package com.billjc.activity.Result;

public class CodeMsg {
	private int code;
	private String msg;

	// 通用异常
	public static CodeMsg SUCCESS = new CodeMsg(0, "success");
	public static CodeMsg SERVER_ERROR = new CodeMsg(500100, "服务端异常");
	
	public static CodeMsg BIND_ERROR = new CodeMsg(500101, "参数校验异常：%s");
	
	public static CodeMsg PROCESS_ERROR = new CodeMsg(500200, "启动流程失败");
    
	private CodeMsg(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	public CodeMsg fillArgs(Object... args) {
		int code = this.code;
		String message = String.format(this.msg, args);
		return new CodeMsg(code, message);
	}

	@Override
	public String toString() {
		return "CodeMsg [code=" + code + ", msg=" + msg + "]";
	}
}
